# 有10个90后的同学，姓名为
# ：[“王一”，“胡二"，“张三”，“李四”，“赵五”，“马六”，“杨七”，“刘八"，“孙九”，“陈十”]
# 为他们随即生成10个生日。需求如下
# 【1】数据存储的格式要求{姓名：生日，姓名：生日，…}
# 【2】输出这10个同学的姓名和生日
# 【3】按季节统计同学出生情况，
# 包含学生个数和具体姓名春季【3月-5月】夏季【6月-8月】秋季【9-11】冬季【12-2】

import random


class Birthday:
    def __init__(self):
        self.name_list = [
            "王一", "胡二", "张三", "李四", "赵五", "马六", "杨七", "刘八", "孙九", "陈十"
        ]
        self.birthday_list = []
        self.generate_birthday()
        self.student_dict = {}

    def generate_birthday(self):
        for i in range(10):
            month = random.randint(1, 12)
            if month == 2:
                day = random.randint(1, 28)
            elif month in (1, 3, 5, 7, 8, 10, 12):
                day = random.randint(1, 31)
            else:
                day = random.randint(1, 30)
            self.birthday_list.append("{}月{}日".format(month, day))

    def student_birthday(self):
        for i in range(10):
            self.student_dict[self.name_list[i]] = self.birthday_list[i]

    def output_birthday(self):
        for key, value in self.student_dict.items():
            print("{} 同学的生日是: {}".format(key, value))

    def seasonal_statistics(self):
        spring = [3, 4, 5]
        summer = [6, 7, 8]
        autumn = [9, 10, 11]
        winter = [12, 1, 2]
        season = ["春季", "夏季", "秋季", "冬季"]
        season_list = [[], [], [], []]
        for key, value in self.student_dict.items():
            temp = value.index("月")
            if eval(value[:temp]) in spring:
                season_list[0].append(key)
            elif eval(value[:temp]) in summer:
                season_list[1].append(key)
            elif eval(value[:temp]) in autumn:
                season_list[2].append(key)
            elif eval(value[:temp]) in winter:
                season_list[3].append(key)

        for i in range(4):
            if len(season_list[i]) > 0:
                print(
                    season[i] + " 出生的学生有{}人，分别是： ".format(len(season_list[i])),
                    *(season_list[i]))
            else:
                print("没有{}出生的学生".format(season[i]))

    def main(self):
        self.student_birthday()
        self.output_birthday()
        self.seasonal_statistics()


if __name__ == "__main__":
    this = Birthday()
    this.main()